using System.Windows;
using System.Windows.Controls;


public partial class TabHeader : UserControl
{
    private bool showmenu;

    public static RoutedEvent CloseTabEvent = EventManager.RegisterRoutedEvent("CloseTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
    public static RoutedEvent CloseAllButTabEvent = EventManager.RegisterRoutedEvent("CloseAllButTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
    public static RoutedEvent SaveTabEvent = EventManager.RegisterRoutedEvent("SaveTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
    public static RoutedEvent SaveAsTabEvent = EventManager.RegisterRoutedEvent("SaveAsTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
    public TabHeader()
    {
        InitializeComponent();

        //CloseAllButTabEvent = EventManager.RegisterRoutedEvent("CloseAllButTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
        //SaveTabEvent = EventManager.RegisterRoutedEvent("SaveTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
        //SaveAsTabEvent = EventManager.RegisterRoutedEvent("SaveAsTab", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TabHeader));
        CloseButton.Click += new RoutedEventHandler(CloseButton_Click);
        CloseMenuItem.Click += new RoutedEventHandler(CloseButton_Click);
        SaveMenuItem.Click += new RoutedEventHandler(SaveMenuItem_Click);
        SaveAsMenuItem.Click += new RoutedEventHandler(SaveAsMenuItem_Click);
        
    }



    public void CloseButton_Click(object sender, RoutedEventArgs e)
    {
        this.RaiseEvent(new RoutedEventArgs(CloseTabEvent));
    }

    public void SaveMenuItem_Click(object sender, RoutedEventArgs e)
    {
        this.RaiseEvent(new RoutedEventArgs(SaveTabEvent));
    }

    public void SaveAsMenuItem_Click(object sender, RoutedEventArgs e)
    {
        this.RaiseEvent(new RoutedEventArgs(SaveAsTabEvent));
    }

    public void SetMenu(bool show)
    {
        if (show == true)
        {
            this.ContextMenu = HeaderMenu;
        }
        else
        {
            this.ContextMenu = null;
        }
        showmenu = show;
    }
}

